<?php

namespace App\Admin\Controllers;

use App\Models\Movie;
use Illuminate\Support\Str;
use SmallRuralDog\Admin\Components\Form\TimePicker;
use SmallRuralDog\Admin\Components\Grid\Boole;
use SmallRuralDog\Admin\Components\Grid\Image;
use SmallRuralDog\Admin\Controllers\AdminController;
use SmallRuralDog\Admin\Form;
use SmallRuralDog\Admin\Grid;

class MovieController extends AdminController
{

    public function grid()
    {

        $grid = new Grid(new Movie());
        $grid->column('id', 'ID')->sortable();
        $grid->column('title', '标题');
        $grid->column('cover', '封面')->component(Image::make()->size(70, 100));
        $grid->column('describe', '描述')->customValue(function ($row, $value) {
            return Str::limit($value, 50);
        });
        $grid->column('rate', '评分');
        $grid->column('released', '发布')->component(Boole::make());
        return $grid;
    }

    public function form($isEdit = false)
    {
        $form = new Form(new Movie());

        $form->item('TimePicker')->component(TimePicker::make()->pickerOptions([
            'start' => '00:00',
            'step' => '00:10',
            'end' => '24:00'
        ]));


        return $form;

    }
}
